<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //有序存储多个元素的容器
        var arr =['李白','韩信','关羽','亚索'];
        console.log( arr[3]);
        //数组名[index] 可以看做变量
        arr[3]="鲁班";
        

        //1.通过索引号，添加元素
        arr[4]="剑圣";
        arr[6]="艾希";
       // console.log(arr[5]); //underfined  只声明未赋值的变量
       
       
       
       
       //2.修改数组的长度，添加元素
       arr.length = 6;

       console.log(arr[4],arr[5]);
       console.log(arr);


       //新建一个数组，里面存放十个整数 1~10
       let arr1 = [];
       //arr1[0]=1;
       //arr1[1]=2;
       //arr1[2]=3;
       //arr1[9]=10;
       for (let i=0;i<10;i++){
        //console.log(i);
        arr1[i]=i+1;

       }
       console.log(arr1);
    </script>
</body>
</html>